/*
fm.im.init执行后layim $ layer等为全局变量
socketClient 也是

init_url: 获取朋友关系等
socket_url: socket的地址
tool：自定义（上传）
moreList：更多
*/
var qnUrl='http://qjqn.foxcodes.cn/';
if( !window["fm"]) fm={};

fm.im = {};
fm.im.init = async function(init_data,tool,moreList,im_handler,im_load){

  let promise_lays = new Promise(function(resolve,fail){
  layui.config({
    version: true,
  }).use(['mobile'], function(){
        var mobile = layui.mobile
        ,layim = mobile.layim
        ,layer = mobile.layer;
        console.log(layui.zepto+"加载配置。。。。。")
        var $ = layui.zepto;
        resolve({$,layim,layer});
      })
  });

  let x = (await promise_lays);

  console.log(x);

  Object.assign(window,x);

  this.config({init:init_data,tool,moreList});
  if(im_handler){
    for(let ev in im_handler){

        layim.on(ev,im_handler[ev]);
    }
  }
  if(im_load){
    im_load();
  }
}


fm.im.config = function(cfg){
 Object.assign(cfg, {
     title:'当前对话'
   ,isgroup: false //是否开启“群聊”
   ,isNewFriend: false // 是否开启“新的朋友”
 });
 layim.config(cfg);
}